<template>
  <div class="search-box">
    <h2>设备检索</h2>
    <el-form label-width="80px">
      <el-form-item label="设备编号">
        <el-input type="text" v-model="formData.id" />
      </el-form-item>
      <el-form-item label="设备名称">
        <el-input type="text" v-model="formData.name" />
      </el-form-item>
      <el-form-item label="设备状态">
        <el-select v-model="formData.status">
          <el-option
            v-for="d in statusList"
            :key="d.id"
            :label="d.name"
            :value="d.id"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="设备分类">
        <el-select v-model="formData.category">
          <el-option
            v-for="d in $store.state.categoryList"
            :key="d.id"
            :label="d.name"
            :value="d.id"
          ></el-option>
        </el-select>
      </el-form-item>
    </el-form>
    <el-button type="primary" @click="submit">查询</el-button>
  </div>
</template>
<script>
// 搜索组件 没有自定义属性，只需要一个值向外抛出即可
export default {
  data() {
    return {
      formData: {
        id: "",
        name: "",
        status: "",
        category: "",
      },
    };
  },
  computed:{
    statusList(){
      if(this.$route.path === '/main/register/list'){
        return this.$store.state
      }else{
        return this.$store.state.equipStatusList
      }
    }
  },
  methods: {
    submit() {
      this.$emit("search", this.formData);
    },
  },
};
</script>
<style lang="sass" scoped>
.search-box
  background-color: #f9f9f9
  border-radius: 5px
  padding: 15px
  h2
    position: relative
    height: 50px
    padding-left: 15px
    font-size: 18px
    &:before
      content: ''
      position: absolute
      top: 5px
      left: 2px
      width: 5px
      height: 16px
      background-color: #1989fa
  .el-button
    width: 100%
</style>
